package com.yunji.web.common;

import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author : peter-zhu
 * @date : 2024/11/16 15:02
 * @description : TODO
 **/
@Data
@Api(tags = "web日志查询通用")
@RestController
@RequestMapping("/weblog")
@ConfigurationProperties(prefix = "weblog")
public class WeblogController {

    private String baseUrl;

    private String detailLogListUrl;

    private String modifyInfoUrl;

    @ApiModelProperty("详情日志")
    @PostMapping("/detailLogList")
    public Object detailLogList(@RequestBody Map<String, Object> dto) {
        String url = baseUrl + detailLogListUrl;
        try (HttpResponse response = HttpUtil.createPost(url)
                .form(dto)
                .execute()) {
            return response.body();
        }
    }

    @ApiModelProperty("查看")
    @PostMapping("/modifyInfo")
    public Object modifyInfo(@RequestBody Map<String, Object> dto) {
        String url = baseUrl + modifyInfoUrl;
        try (HttpResponse response = HttpUtil.createPost(url)
                .form(dto)
                .execute()) {
            return response.body();
        }
    }
}
